<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>canvas-3</title>
<style>
	body{
		text-align: center;
	}	
	#c{
		border: 1px solid #000;
	}
</style>
</head>
<canvas id="c" width="800" height="600">
	
</canvas>
<script>
	var ctx=c.getContext("2d");
	var g=ctx.createLinearGradient(400,150,400,300);
	g.addColorStop(0, '#f00');		//添加颜色点
  	g.addColorStop(0.5, '#ff0');		//添加颜色点
  	g.addColorStop(1, '#0f0');
	ctx.fillStyle=g;
	ctx.fillRect(200,150,400,300);
</script>
<body>
</body>
</html>
